package cn.yy.mobile_erp.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import cn.yy.mobile_erp.pojo.User;
import cn.yy.mobile_erp.tool.Constants;


public class SysInterceptor extends HandlerInterceptorAdapter {
	//private Logger logger = Logger.getLogger(SysInterceptor.class);
	
	public boolean preHandle(HttpServletRequest request,HttpServletResponse response,Object handler) throws Exception{
		System.out.println("进入SysInterceptor preHandle ==========================");
		HttpSession session=request.getSession();
		session.setMaxInactiveInterval(3600);
		User user=(User)session.getAttribute(Constants.USER_SESSION);
		
		if(null==user){
			response.sendRedirect(request.getContextPath()+"/401.jsp");
			return false;
		}
		return true;
	}
}
